<?php
require_once "aliyun/mqs/mqs.class.php";
class AliMQS
{
    private $mqs;
    
    public function __construct() {
        $this->mqs = new Message("cvqDdOmwp43Cz4hZ","OaNM29EY6VwRGItVdZJcYkfvHQppHY","ag74kayzc1","mqs-cn-hangzhou-internal.aliyuncs.com");
    }
    
    public function sendMessage($queueName,$message)
    {
        $this->mqs->SendMessage($queueName,$message);
    }
    
    public function reveiveMessage($queueName) {
        $message=$this->mqs->ReceiveMessage($queueName,5);		//接收消息列队里的消息
        if($message['state']=='ok'){
            return $message['msg'];
        }
        return null;
    }
    
    public function deleteMessage($queueName,$message) {
        $this->mqs->DeleteMessage($queueName,$message['ReceiptHandle']);
    }
}